<template>
  <div class="mv">
      <div class="mv_info">
        <div
          class="mv_list"
          v-for="(index, id) in mv_list.info"
          :key="index.id"
          @mouseenter="en_mv(id)"
          @mouseleave="le_mv"
          @click="play_mv(index.hash)"
        >
          <div class="showdow" :class="{ block: mv_show == id }">
            <span class="iconfont icon-24gl-play"></span>
          </div>
          <img v-lazy="index.imgurl" alt="" />
          <p
            @mouseenter="en_mv_p(id)"
            @mouseleave="le_mv_p"
            :class="{ color: mv_p_color == id }"
          >
            {{ index.filename }}
          </p>
        </div>
      </div>
      <!-- mv播放盒子 -->

      <mvplay :mv_img="mv_img" v-show="mv_block"/>
    </div>
</template>

<script>

import { mapState } from 'vuex';
export default {
  data(){
    return{
      //鼠标移入mv背景
      mv_show: null,
      mv_p_color: null,
      //mv播放url
      mv_img: "",
      //mv播放的显示
      mv_block:false,

      
    }
    
  },

  props:["mv_list"],
  mounted(){
    this.$bus.$on("show_mv",()=>{
      this.mv_block=false
      this.mv_img=''
    })
  },
  methods:{
    //mv播放
    async play_mv(index) {
      await this.$store.dispatch("mv_play", index);
      //数据给予
      this.mv_img = this.mv_play.backupdownurl[0];
      //播放盒子的显示
      this.mv_block=true
    },
    //播放盒子的叉
    nono_play(){
      this.mv_block=false
      this.mv_img=""
    },
    //mv页面间交互效果
    en_mv(index) {
      this.mv_show = index;
    },
    le_mv() {
      this.mv_show = null;
    },
    //字体
    en_mv_p(index) {
      this.mv_show = null;
      this.mv_p_color = index;
    },
    le_mv_p() {
      this.mv_p_color = null;
    },
    
  },
  computed:{
    ...mapState({
      mv_play: (state) => state.song.mv_play.sq,
    })
  }
}
</script>

<style lang="less">
.mv {
    cursor: pointer;
    .mv_info {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      .mv_list {
        width: 180px;
        margin-bottom: 15px;
        position: relative;
        .showdow {
          display: none;
          width: 180px;
          height: 100px;
          background-color: #000;
          opacity: 0.5;
          position: absolute;

          .icon-24gl-play {
            position: absolute;
            font-size: 40px;
            top: 30px;
            left: 75px;
            color: #fff;
          }
        }
        .block {
          display: block;
        }

        img {
          border-radius: 5px;
          height: 100px;
          margin-bottom: 5px;
        }
        p {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          font-size: 16px;
        }
        .color {
          color: #00a9ff;
        }
      }
      .mv_list:last-child:nth-child(5n-1) {
        margin-right: 205px;
      }
      .mv_list:last-child:nth-child(5n-2) {
        margin-right: 410px;
      }
      .mv_list:last-child:nth-child(5n-3) {
        margin-right: 615px;
      }
    }
  }
//mv播放盒子
  .void {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    width: 600px;
    height: 340px;

    video {
      width: 100%;
      height: 100%;
      border-radius: 5px;
      background-color: #000;
    }
    .icon-chahao {
      position: absolute;
      width: 25px;
      height: 25px;
      top: -12.5px;
      right: -12.5px;
      background-color: #fff;
      border-radius: 12.5px;
      font-size: 25px;
    }
  }
</style>